#ifndef MONITOR_H
#define MONITOR_H

#include <QDialog>
#include <QTimer>
#include <QPainter>
#include <QImage>
#include <QPaintEvent>
#include <QMessageBox>
#include <QPixmap>

#include "videodevice.h"


namespace Ui {
class Monitor;
}

class Monitor : public QDialog
{
    Q_OBJECT
    
public:
    explicit Monitor(QWidget *parent = 0);
    ~Monitor();

private:
    QPainter *painter;
//    QLabel *label;
    QImage *frame;
    //QPixmap *frame;
    QTimer *timer;
    int rs;
    uchar *pp;
    uchar * p;
    unsigned int len;
    int convert_yuv_to_rgb_pixel(int y, int u, int v);
    int convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height);
    VideoDevice *vd;

private slots:
    void paintEvent(QPaintEvent *);
    void display_error(QString err);
    
private:
    Ui::Monitor *ui;
};

#endif // MONITOR_H
